const alert = (...data) => console.log('alert: ', ...data)

function close() {
    function outer() {
        var i = 1;
        (function inner() { // inner闭包： 他可以拿到outer内部变量； 自执行函数
            i += 1;
        })();
        console.log(i);
    }

    outer();
}

function rex() {
    const regex = /[0-9]/g;
    const str = `EZpv-EN`;
    console.log(regex.exec(str))
}

function OriginObj() {
    this.name = 'name';
    return this;
}

function myNew(fn, ...args) {
    let instance = Object.create(fn.prototype);
    let res = fn.apply(instance, args);
    return typeof res === 'object' ? res : instance;
}
function testProxy() {
    var target = {};
    var handler = {
        get: function (target, property) {
            console.log(target, property);
            return 'this is proxy get';
        }
    };
    var proxy = new Proxy(target, handler);
    proxy.a = 'b';
    console.log(proxy.a) // "b"
}

var proxy = new Proxy({}, {
    get: function (target, property) {
        console.log('real value', target[property], target, property);
        if (property === '__proto__') {
            return target.__proto__
        }
        return 35;
    }
});

let obj = Object.create(proxy);
Object.defineProperty(obj, 'time', {
    get: () => 'time',
})
console.log(obj);
console.log(obj.time, obj.property); // 35
console.log(obj.__proto__.time, obj.name);
